const cloud = require("@cloudbase/node-sdk");

const app = cloud.init({
    env: cloud.SYMBOL_CURRENT_ENV,
});

var db = app.database();
const _ = db.command
const ZXContact = db.collection('ZX-Contact')

// 获取openId云函数入口函数
exports.main = async (event, context) => {

    var _id = event.data._id
    var type = event.data.type
    
    if(type==='detail'){
        return await ZXContact.get()
    }
    if (_id){
        delete event.data._id
        return await ZXContact.doc(_id).update(event.data)
    }
    
};